﻿/*---------------------------------------------------------------------------
	ZaRan	-	A Totallly Automatic CFD Software
	Copyright (C) ,Since 2020
-------------------------------------------------------------------------------
License
	This file is part of ZaRan.

!	@file		gird.h
!	@brief	the purpose of this file.
!	@author	Chen Jie.
\*---------------------------------------------------------------------------*/
#pragma once
#include<vector>
#include"utility/include/math.h"
using std::vector;
/*
几何基础名称空间
由点、线、面基础类构成
*/
class Point
{
public:
	Point(double x = 0, double y = 0, double z = 0);
	Point(const Point& pt);
	const double& x() const { return coord_[0]; }
	const double& y() const { return coord_[1]; }
	const double& z() const { return coord_[2]; }
	void ChangeX(const double x);
	void ChangeY(const double y);
	void ChangeZ(const double z);
	void ChangeCoord(const double x, const double y, const double z = 0);
	virtual bool operator ==(const Point& pt)const
	{
		double delta = 1e-15;
		return abs(coord_[0] - pt.coord_[0]) < delta && abs(coord_[1] - pt.coord_[1]) < delta && abs(coord_[2] - pt.coord_[2]) < delta;
	};
private:
	double coord_[3];
};


class Segment
{
public:
	Segment(Point& pt1, Point& pt2);
	Segment() {};
	bool operator ==(const Segment& ln)
	{
		return point_[0] == ln.point_[0] && point_[1] == ln.point_[1];
	};
	double Distance(const Point& pt);
private:
	Point point_[2];
};
class Polygon
{
public:
	Polygon() {};
	void AddPoint(Point& pt);
	void AddEdge(Segment& ln);
private:
	vector <Point> point_;
	vector <Segment> edge_;
	Point cent_;
};

